#include<stdio.h>
int main()
{
	int num,i,sum=0,count,n,t;
	scanf("%d",&num);
	t=num;
	for(count=0;num>0;count++){
	num/=10;}
	int arr[count];
	for(i=0;i<count;i++){
	arr[i]=t%10;
	t/=10;}
	for(i=0;i<count;i++)
	{
		n=arr[i];
		sum+=n*n;
	}
	printf("%d",sum);
	return 0;
 } 
